%pcell是一个1*N的cell变量，N为质点总数，每个元素为一个一维数组，代表该质点随时间变化的某个物理量
%tau = t0 * 1e-6 * step代表样本的采样时间间隔
function fourier_series = Fourier_Series(pcell, tau)
    N = length(pcell);
    sam_len = length(pcell{1});
    
    fourier_series = zeros(1,sam_len);
    
    %求傅里叶级数系数的模平方和
    for k = 1:sam_len
        ak = 0;
        for j = 1:N
            ak_j = 0;
            for n = 1:sam_len
                ak_j = ak_j + pcell{j}(n) * exp(-1i * k * (2*pi)/sam_len * tau * n);
            end
            ak_j = ak_j/sam_len;
            ak = ak + abs(ak_j)^2;
        end
        fourier_series(k) = 2 * ak; %有系数2是因为物理量为实数，a_{k} = a_{-k}
    end    

    return
end